package com.gagakuai.domain.mapstruct;


import com.gagakuai.base.BaseMapper;
import com.gagakuai.domain.dto.LogSmallDTO;
import com.gagakuai.domain.entity.Log;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;

import java.util.Arrays;


@Mapper(componentModel = "spring", uses = { Arrays.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface LogSmallMapper extends BaseMapper<LogSmallDTO, Log> {

    @Mapping(target = "exceptionDetail",expression = "java(new String(entity.getExceptionDetail()==null? new byte[1]:entity.getExceptionDetail()))")
    LogSmallDTO toDto(Log entity);

    @Mapping(target = "exceptionDetail",expression = "java(dto.getExceptionDetail().getBytes())")
    Log toEntity(LogSmallDTO dto);


}
